package com.yuma.account.controller;

import com.yuma.account.entity.Account;
import com.yuma.account.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class AccountController {
    @Autowired
    private AccountService accountService;
    /**
     * 扣减余额
     */
    @GetMapping("/debit")
    public String debit(@RequestParam("userId") Long userId,
                        @RequestParam("money") BigDecimal money) {
        Account account = new Account();
        account.setUserId(userId).setMoney(money);
        accountService.updateByUserId(account);
        return "account success";
    }
}
